
def count_game(list):
    count_dict = {}
    for game in list:
        if game not in count_dict:
            count_dict[game] = 1
        else:
            count_dict[game] += 1
    return count_dict


with open('4班.txt', 'rb') as fd:
    text = fd.read().decode('utf-8')
    text_list = text.split('\r\n')
    count_dict = count_game(text_list)
    count_sort = sorted(count_dict.items(), key=lambda item: item[1], reverse=True)
    print(count_sort)
